package com.sxj.springsourcecode.springframework.io.support;

import com.sxj.springsourcecode.springframework.factory.config.BeanDefinitionRegistry;
import com.sxj.springsourcecode.springframework.io.BeanDefinitionReader;
import com.sxj.springsourcecode.springframework.io.config.Resource;
import com.sxj.springsourcecode.springframework.io.config.ResourceLoader;

/**
 * @ProjectName: spring-source-code
 * @Package: com.sxj.springsourcecode.springframework.io.support
 * @ClassName: AbstractBeanDefinitionReader
 * @Author: sxj
 * @Description:
 * @Date: 2024/2/21 22:45
 * @Version: 1.0.0
 */
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {
    private BeanDefinitionRegistry registry;

    private ResourceLoader resourceLoader;

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
        this.registry = registry;
        this.resourceLoader = new DefaultResourceLoader();
    }

    @Override
    public void loadBeanDefinitions(String location) {
        Resource resource = getResourceLoader().getResource(location);
        loadBeanDefinitions(resource);
    }

    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }

    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }
}
